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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use iloc
when computing faithfulness metric
#11117
Conversation
Documentation preview for 83ccbdc will be available when this CircleCI job completes successfully. More info
|
mlflow/metrics/genai/genai_metric.py
Outdated
@@ -31,7 +31,7 @@ def _format_args_string(grading_context_columns: Optional[List[str]], eval_value | |||
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the existing code assumes that inputs
, outputs
, and eval_values[arg]
have the same indices and throws when they don't.
mlflow/mlflow/metrics/genai/genai_metric.py
Lines 277 to 300 in cc184ee
grading_payloads = [] | |
for indx, (input, output) in enumerate(zip(inputs, outputs)): | |
try: | |
arg_string = _format_args_string(grading_context_columns, eval_values, indx) | |
except Exception as e: | |
raise MlflowException( | |
f"Values for grading_context_columns are malformed and cannot be " | |
f"formatted into a prompt for metric '{name}'.\n" | |
f"Required columns: {grading_context_columns}\n" | |
f"Values: {eval_values}\n" | |
f"Error: {e!r}\n" | |
f"Please check the following: \n" | |
"- predictions and targets (if required) are provided correctly\n" | |
"- grading_context_columns are mapped correctly using the evaluator_config " | |
"parameter\n" | |
"- input and output data are formatted correctly." | |
) | |
grading_payloads.append( | |
evaluation_context["eval_prompt"].format( | |
input=(input if include_input else None), | |
output=output, | |
grading_context_columns=arg_string, | |
) | |
) |
In the new code, they don't have to have the same indices.
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
@@ -769,6 +769,14 @@ def test_faithfulness_metric(): | |||
examples=[mlflow_example], | |||
) | |||
|
|||
faithfulness_metric.eval_fn( | |||
# Inputs with different indices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: the error is rather because of index not starting from 0 I guess?
for indx, (input, output) in enumerate(zip(inputs, outputs)):
try:
arg_string = _format_args_string(grading_context_columns, eval_values, indx)
The indx
always starts from 0 (cuz we do enumerate) and eval_values[0]
will raise KeyError if it doesn't have index 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, reset_index(drop=True)
should also work as @ai-learner-00 explained in #11108
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup I think the current solution is fine, plz feel free to merge. Just wanted to make sure the ^comment is accurate:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com>
Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> Signed-off-by: Arthur Jenoudet <arthur.jenoudet@databricks.com>
馃洜 DevTools 馃洜
Install mlflow from this PR
Checkout with GitHub CLI
Related Issues/PRs
Resolve #11108
What changes are proposed in this pull request?
How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/artifacts
: Artifact stores and artifact loggingarea/build
: Build and test infrastructure for MLflowarea/deployments
: MLflow Deployments client APIs, server, and third-party Deployments integrationsarea/docs
: MLflow documentation pagesarea/examples
: Example codearea/model-registry
: Model Registry service, APIs, and the fluent client calls for Model Registryarea/models
: MLmodel format, model serialization/deserialization, flavorsarea/recipes
: Recipes, Recipe APIs, Recipe configs, Recipe Templatesarea/projects
: MLproject format, project running backendsarea/scoring
: MLflow Model server, model deployment tools, Spark UDFsarea/server-infra
: MLflow Tracking server backendarea/tracking
: Tracking Service, tracking client APIs, autologgingInterface
area/uiux
: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/docker
: Docker use across MLflow's components, such as MLflow Projects and MLflow Modelsarea/sqlalchemy
: Use of SQLAlchemy in the Tracking Service or Model Registryarea/windows
: Windows supportLanguage
language/r
: R APIs and clientslanguage/java
: Java APIs and clientslanguage/new
: Proposals for new client languagesIntegrations
integrations/azure
: Azure and Azure ML integrationsintegrations/sagemaker
: SageMaker integrationsintegrations/databricks
: Databricks integrationsHow should the PR be classified in the release notes? Choose one:
rn/none
- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/breaking-change
- The PR will be mentioned in the "Breaking Changes" sectionrn/feature
- A new user-facing feature worth mentioning in the release notesrn/bug-fix
- A user-facing bug fix worth mentioning in the release notesrn/documentation
- A user-facing documentation change worth mentioning in the release notes