Skip to content

Commit

Permalink
Use iloc when computing faithfulness metric (mlflow#11117)
Browse files Browse the repository at this point in the history
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: Arthur Jenoudet <arthur.jenoudet@databricks.com>
  • Loading branch information
harupy authored and artjen committed Mar 26, 2024
1 parent 5e1425c commit 054ae64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion mlflow/metrics/genai/genai_metric.py
Expand Up @@ -28,10 +28,16 @@


def _format_args_string(grading_context_columns: Optional[List[str]], eval_values, indx) -> str:
import pandas as pd

args_dict = {}
for arg in grading_context_columns:
if arg in eval_values:
args_dict[arg] = eval_values[arg][indx]
args_dict[arg] = (
eval_values[arg].iloc[indx]
if isinstance(eval_values[arg], pd.Series)
else eval_values[arg][indx]
)
else:
raise MlflowException(
f"{arg} does not exist in the eval function {list(eval_values.keys())}."
Expand Down
8 changes: 8 additions & 0 deletions tests/metrics/genai/test_genai_metrics.py
Expand Up @@ -769,6 +769,14 @@ def test_faithfulness_metric():
examples=[mlflow_example],
)

faithfulness_metric.eval_fn(
# Inputs with different indices
pd.Series([mlflow_prediction], index=[0]),
{},
pd.Series([input], index=[1]),
pd.Series([mlflow_ground_truth], index=[2]),
)


def test_answer_correctness_metric():
answer_correctness_metric = answer_correctness()
Expand Down

0 comments on commit 054ae64

Please sign in to comment.