Skip to content
Open
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
11 changes: 8 additions & 3 deletions ai4rag/core/experiment/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,19 @@ def optimization_metric(self) -> str:
@optimization_metric.setter
def optimization_metric(self, val: str) -> None:
"""Validate and set optimization metrics"""
if val not in MetricType:
if val not in MetricType and not self._is_custom_evaluator_metric(val):
raise RAGExperimentError(
f"Provided optimization metric: '{val}' is not supported. "
f"Available metrics: ['answer_correctness', 'faithfulness', 'context_correctness']."
f"Provided optimization metric: '{val}' is not supported. " f"Available metrics: {list(MetricType)}."
)

self._optimization_metric = val

def _is_custom_evaluator_metric(self, metric_name: str) -> bool:
"""Check if a metric is supported by a custom evaluator."""
if hasattr(self, "evaluator") and hasattr(self.evaluator, "get_supported_metrics"):
return metric_name in self.evaluator.get_supported_metrics()
return False

@property
def benchmark_data(self) -> BenchmarkData:
"""Get benchmark data."""
Expand Down
8 changes: 8 additions & 0 deletions ai4rag/evaluator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@
# -----------------------------------------------------------------------------
from ai4rag.evaluator.base_evaluator import BaseEvaluator
from ai4rag.evaluator.unitxt_evaluator import UnitxtEvaluator

try:
from ai4rag.evaluator.mlflow_llm_judge_evaluator import (
LLMJudgeConfig,
MlflowLLMJudgeEvaluator,
)
except ImportError:
pass
Comment on lines +8 to +14

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using silent pass when we end up in the import error seems not like an option. We should AT LEAST log something on the info level.

1 change: 1 addition & 0 deletions ai4rag/evaluator/base_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class MetricType(metaclass=ConstantMeta):
ANSWER_CORRECTNESS = "answer_correctness"
FAITHFULNESS = "faithfulness"
CONTEXT_CORRECTNESS = "context_correctness"
ANSWER_RELEVANCE = "answer_relevance"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This minimal mention in the docstring to follow used convention would be appreciated



class BaseEvaluator(ABC):
Expand Down
Loading
Loading