We measure accuracy and relevance to know how well an AI agent answers questions or solves tasks. This helps us trust and improve the agent.
Measuring agent accuracy and relevance in Agentic AI
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Syntax
Agentic AI
accuracy = (number of correct answers) / (total answers) relevance = (number of relevant answers) / (total answers)
Accuracy measures how many answers are exactly right.
Relevance measures how many answers are useful or related, even if not perfect.
Examples
Agentic AI
accuracy = 8 / 10 # 8 correct out of 10 answers relevance = 9 / 10 # 9 relevant out of 10 answers
Agentic AI
accuracy = correct_predictions / total_predictions relevance = relevant_responses / total_responses
Sample Model
This program calculates and prints accuracy and relevance for an AI agent's answers.
Agentic AI
correct_answers = 7 relevant_answers = 9 total_answers = 10 accuracy = correct_answers / total_answers relevance = relevant_answers / total_answers print(f"Accuracy: {accuracy:.2f}") print(f"Relevance: {relevance:.2f}")
Important Notes
Accuracy is strict; only fully correct answers count.
Relevance allows some flexibility; answers can be helpful even if not perfect.
Always check both to get a full picture of agent performance.
Summary
Accuracy shows how many answers are exactly right.
Relevance shows how many answers are useful or related.
Measuring both helps improve and trust AI agents.
Practice
1. What does accuracy measure when evaluating an AI agent's answers?
easy
Solution
Step 1: Understand accuracy definition
Accuracy counts the number of answers that match the correct ones exactly.Step 2: Compare with other metrics
Relevance measures usefulness, not exact correctness, so it is different from accuracy.Final Answer:
How many answers are exactly correct -> Option CQuick Check:
Accuracy = exact correctness [OK]
Hint: Accuracy means exact right answers only [OK]
Common Mistakes:
- Confusing accuracy with relevance
- Thinking accuracy measures speed
- Assuming accuracy counts all related answers
2. Which of the following is the correct way to calculate accuracy for an AI agent's answers?
easy
Solution
Step 1: Recall accuracy formula
Accuracy = (correct answers) / (total answers given).Step 2: Eliminate incorrect options
Options about related answers or speed do not define accuracy.Final Answer:
Number of correct answers divided by total answers -> Option BQuick Check:
Accuracy = correct / total [OK]
Hint: Accuracy = correct answers รท total answers [OK]
Common Mistakes:
- Using related answers count instead of correct
- Mixing speed with accuracy
- Ignoring total number of answers
3. Given an AI agent answered 80 questions, 60 were exactly correct, and 10 more were relevant but not exact. What is the accuracy and relevance percentage?
medium
Solution
Step 1: Calculate accuracy percentage
Accuracy = (60 correct / 80 total) * 100 = 75%.Step 2: Calculate relevance percentage
Relevance = ((60 correct + 10 relevant) / 80 total) * 100 = 87.5%.Final Answer:
Accuracy 75%, Relevance 87.5% -> Option DQuick Check:
Accuracy = 75%, Relevance = 87.5% [OK]
Hint: Add relevant to correct for relevance % [OK]
Common Mistakes:
- Mixing accuracy and relevance values
- Not adding relevant answers for relevance
- Dividing by wrong total number
4. An AI agent evaluation code snippet is below. It calculates accuracy but returns 0. What is the bug?
correct = 50 total = 0 accuracy = correct / total print(accuracy)
medium
Solution
Step 1: Identify variables and operation
correct = 50, total = 0, accuracy = correct / total.Step 2: Check for division errors
Dividing by zero (total=0) causes an error or invalid result.Final Answer:
Division by zero error due to total being zero -> Option AQuick Check:
Division by zero causes error [OK]
Hint: Check denominator is not zero before dividing [OK]
Common Mistakes:
- Ignoring zero division error
- Thinking print syntax is wrong
- Assuming accuracy must be multiplied by 100
5. You want to improve an AI agent's trust by measuring both accuracy and relevance. Which approach best helps achieve this?
hard
Solution
Step 1: Understand trust factors
Trust improves when answers are both correct and useful (relevant).Step 2: Choose measurement approach
Tracking both exact correctness (accuracy) and usefulness (relevance) gives a fuller picture.Final Answer:
Track exact correct answers and also count useful related answers -> Option AQuick Check:
Measure accuracy + relevance for trust [OK]
Hint: Measure both exact and useful answers for trust [OK]
Common Mistakes:
- Focusing only on exact correctness
- Ignoring relevance completely
- Measuring speed instead of quality
