Skip to content

Commit

Permalink
[Evaluation] Change RougeType to Enum (Azure#38131)
Browse files Browse the repository at this point in the history
* Change RougeType to Enum

* update test recording

* update assets.json

* try to update recordings to fix the failed tests

* update

* revert assets.json

* update
  • Loading branch information
ninghu authored and allenkim0129 committed Nov 5, 2024
1 parent bb075f5 commit 5ca4f33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sdk/evaluation/azure-ai-evaluation/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5ca4f33

Please sign in to comment.