Attach metadata to a model
Learn how to attach metadata to a model.
ZenML allows you to log metadata for models, which provides additional context that goes beyond individual artifact details. Model metadata can represent high-level insights, such as evaluation results, deployment information, or customer-specific details, making it easier to manage and interpret the model's usage and performance across different versions.
Logging Metadata for Models
To log metadata for a model, use the log_metadata
function. This function lets you attach key-value metadata to a model, which can include metrics and other JSON-serializable values, such as custom ZenML types like Uri
, Path
, and StorageSize
.
Here's an example of logging metadata for a model:
In this example, the metadata is associated with the model rather than the specific classifier artifact. This is particularly useful when the metadata reflects an aggregation or summary of various steps and artifacts in the pipeline.
Selecting Models with log_metadata
log_metadata
When using log_metadata
, ZenML provides flexible options of attaching metadata to model versions:
Using
infer_model
: If used within a step, ZenML will use the step context to infer the model it is using and attach the metadata to it.Model Name and Version Provided: If both a model name and version are provided, ZenML will use these to identify and attach metadata to the specific model version.
Model Version ID Provided: If a model version ID is directly provided, ZenML will use it to fetch and attach the metadata to that specific model version.
Fetching logged metadata
Once metadata has been attached to a model, it can be retrieved for inspection or analysis using the ZenML Client.
When you are fetching metadata using a specific key, the returned value will always reflect the latest entry.
Last updated