Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Evaluation] Change RougeType to Enum #38131

Merged
merged 10 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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