Logging metadata
Tracking your metadata.
Metadata plays a critical role in ZenML, providing context and additional information about various entities within the platform. Anything which is metadata
in ZenML can be compared in the dashboard.
This guide will explain how to log metadata for artifacts and model versions in ZenML and detail the types of metadata that can be logged.
Logging Metadata for Artifacts
Artifacts in ZenML are outputs of steps within a pipeline, such as datasets, models, or evaluation results. Associating metadata with artifacts can help users understand the nature and characteristics of these outputs.
To log metadata for an artifact, you can use the log_artifact_metadata
method. This method allows you to attach a dictionary of key-value pairs as metadata to an artifact. The metadata can be any JSON-serializable value, including custom classes such as Uri
, Path
, DType
, and StorageSize
.
Here's an example of logging metadata for an artifact:
Logging Metadata for Model Versions
While artifact metadata is specific to individual outputs of steps, model version metadata encapsulates broader and more general information that spans across multiple artifacts. For example, evaluation results or the name of a customer for whom the model is intended could be logged with the model version.
Here's an example of logging metadata for a model version:
In this example, the metadata is associated with the model version 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.
Grouping Metadata in the Dashboard
When logging metadata passing a dictionary of dictionaries in the metadata
parameter will group the metadata into cards in the ZenML dashboard. This feature helps organize metadata into logical sections, making it easier to visualize and understand.
Here's an example of grouping metadata into cards:
In the ZenML dashboard, "model_metrics" and "data_details" would appear as separate cards, each containing their respective key-value pairs.
Examples of Special Metadata Types
ZenML supports several special metadata types to capture specific kinds of information. Here are examples of how to use the special types Uri
, Path
, DType
, and StorageSize
:
In this example:
Uri
is used to indicate a dataset source URI.Path
is used to specify the filesystem path to a preprocessing script.DType
is used to describe the data types of specific columns.StorageSize
is used to indicate the size of the processed data in bytes.
These special types help standardize the format of metadata and ensure that it is logged in a consistent and interpretable manner.
Conclusion
Choosing whether to log metadata with artifacts or model versions depends on the scope and purpose of the information you wish to capture. Artifact metadata is best for details specific to individual outputs, while model version metadata is suitable for broader information relevant to the overall model. By utilizing ZenML's metadata logging capabilities and special types, you can enhance the traceability, reproducibility, and analysis of your ML workflows.
Last updated