yocto-gl icon indicating copy to clipboard operation
yocto-gl copied to clipboard

Deprecate `generate_signature_output` in favor of input_example

Open B-Step62 opened this issue 4 months ago • 3 comments

Summary

The mlflow.transformers.generate_signature_output function is an utility function for generating prediction output for a Transformers model, so that users can pass it to the mlflow.models.infer_signature for getting the auto-inferred model signature for the model.

However, MLflow now support inferring signature from input_example specified when logging a model. Users no longer need this API and can just pass an input example to let MLflow infer the signature.

We should mark the generate_signature_output deprecated, as well as update the examples and tutorials in the documentation.

Old

signature = mlflow.models.infer_signature(
    input_example,
    mlflow.transformers.generate_signature_output(generation_pipeline, input_example),
    parameters,
)

with mlflow.start_run() as run:
    model_info = mlflow.transformers.log_model(
        transformers_model=generation_pipeline,
        artifact_path="text_generator",
        input_example=["prompt 1", "prompt 2", "prompt 3"],
        signature=signature,
    )

Current

with mlflow.start_run() as run:
    model_info = mlflow.transformers.log_model(
        transformers_model=generation_pipeline,
        artifact_path="text_generator",
        # By passing a tuple of input example and parameters, MLflow can infer model signature including parameters.
        input_example=(["prompt 1", "prompt 2", "prompt 3"], parameters)
    )

Notes

  • Make sure to open a PR from a non-master branch.

  • Sign off the commit using the -s flag when making a commit:

    git commit -s -m "..."
             # ^^ make sure to use this
    
  • Include #{issue_number} (e.g. #123) in the PR description when opening a PR.

B-Step62 avatar Oct 05 '24 11:10 B-Step62