When evaluating autonomous agents, it is recommended to use metrics that focus on binary decisions or discrete classification scores rather than ambiguous continuous scales. Ragas provides two primary ways to implement this:
- AspectCritic: Evaluates whether a submission follows specific user-defined criteria (e.g., brand tone or request completeness) using LLM judgments to return a binary outcome (1 or 0).
- RubricsScore: Assesses responses against a detailed, user-defined rubric to assign scores based on specific qualitative descriptions.
Both metrics require an llm (wrapped via LangchainLLMWrapper) to perform the evaluation.
from ragas.metrics import AspectCritic, RubricsScore
from ragas.dataset_schema import SingleTurnSample, MultiTurnSample, EvaluationDataset
from ragas import evaluate
# Example: Using RubricsScore for recommendation quality
rubrics = {
"score-1_description": (
"The item requested by the customer is not present in the menu and no recommendations were made."
),
"score0_description": (
"Either the item requested by the customer is present in the menu, or the conversation does not include any food or menu inquiry (e.g., booking, cancellation). This score applies regardless of whether any recommendation was provided."
),
"score1_description": (
"The item requested by the customer is not present in the menu and a recommendation was provided."
),
}
recommendations = RubricsScore(rubrics=rubrics, llm=evaluator_llm, name="Recommendations")
# Example: Using AspectCritic for binary compliance (e.g., Request Completeness)
request_completeness = AspectCritic(
name="Request Completeness",
llm=evaluator_llm,
definition=(
"Return 1 The agent completely fulfills all the user requests with no omissions. "
"otherwise, return 0."
),
)
# Example: Using AspectCritic for Brand Voice
brand_tone = AspectCritic(
name="Brand Voice Metric",
llm=evaluator_llm,
definition="Return 1 if the AI's communication is friendly, approachable, helpful, clear, and concise; otherwise, return 0.",
)