From 5ca4f3384bbe5a182a5ad533ba37f7aa03adfbb9 Mon Sep 17 00:00:00 2001 From: Billy Hu Date: Tue, 29 Oct 2024 15:30:07 -0700 Subject: [PATCH] [Evaluation] Change RougeType to Enum (#38131) * Change RougeType to Enum * update test recording * update assets.json * try to update recordings to fix the failed tests * update * revert assets.json * update --- sdk/evaluation/azure-ai-evaluation/assets.json | 2 +- .../azure/ai/evaluation/_evaluators/_rouge/_rouge.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sdk/evaluation/azure-ai-evaluation/assets.json b/sdk/evaluation/azure-ai-evaluation/assets.json index 8483a02c668b..a4682c68823c 100644 --- a/sdk/evaluation/azure-ai-evaluation/assets.json +++ b/sdk/evaluation/azure-ai-evaluation/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/evaluation/azure-ai-evaluation", - "Tag": "python/evaluation/azure-ai-evaluation_eb4989f81d" + "Tag": "python/evaluation/azure-ai-evaluation_e3ec13551e" } diff --git a/sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_rouge/_rouge.py b/sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_rouge/_rouge.py index 6b7a84d5db92..13ec0f8eef98 100644 --- a/sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_rouge/_rouge.py +++ b/sdk/evaluation/azure-ai-evaluation/azure/ai/evaluation/_evaluators/_rouge/_rouge.py @@ -6,10 +6,9 @@ from promptflow._utils.async_utils import async_run_allowing_running_loop from azure.ai.evaluation._vendor.rouge_score import rouge_scorer -from azure.core import CaseInsensitiveEnumMeta -class RougeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): +class RougeType(Enum): """ Enumeration of ROUGE (Recall-Oriented Understudy for Gisting Evaluation) types. """ @@ -38,8 +37,8 @@ def __init__(self, rouge_type: RougeType): self._rouge_type = rouge_type async def __call__(self, *, ground_truth: str, response: str, **kwargs): - scorer = rouge_scorer.RougeScorer(rouge_types=[self._rouge_type]) - metrics = scorer.score(ground_truth, response)[self._rouge_type] + scorer = rouge_scorer.RougeScorer(rouge_types=[self._rouge_type.value]) + metrics = scorer.score(ground_truth, response)[self._rouge_type.value] return { "rouge_precision": metrics.precision, "rouge_recall": metrics.recall,