liveBook · Manning

Model artifact

As explained in Machine Learning Platform Engineering

A model artifact type is a KFP artifact type representing a trained machine-learning model and its framework-specific metadata.

A KFP Model artifact represents a trained machine-learning model in a pipeline. Use it for trained models, checkpoints, weights, or pretrained model artifacts. Its type supports framework-specific metadata and helps track lineage from training data and parameters to the resulting model. section 7.2.3

@dsl.component
def train_model(dataset: Input[Dataset], 
                model: Output[Model]):
                    trained_model = train(dataset.path)
                    trained_model.save(model.path)

A training component consumes an Input[Dataset], produces an Output[Model], and saves the trained model at the output artifact’s path. section 7.2.3

Downstream components declare Input[Model] to receive that output. Keep the roles distinct: Dataset carries validation data, Model carries the trained weights, and Metrics records evaluation results. section 7.2.3 section 8.1.4

Listing 8.13 Loading the YOLO model and computing validation metrics
@dsl.component(...)
def validate_model(...):
   from ultralytics import YOLO
   import os

   model_path = os.path.join(model.path, "best.pt") #1
   model = YOLO(model_path)

   val_results = model.val( #2
       data=os.path.join(data_yaml.path, "data.yaml"),
       imgsz=640,
       batch=1,
       verbose=True
   )

   metrics.log_metric("map50-95", val_results.box.map) #3
   metrics.log_metric("map50", val_results.box.map50)   #3
   metrics.log_metric("map75", val_results.box.map75)   #3

In the YOLO validation component, the model is loaded from best.pt under model.path. Validation then logs mAP values to Output[Metrics], rather than treating those measurements as the model artifact. section 8.1.4

For tracking across experiments, MLflow provides centralized model artifact storage and model lineage tracking. Its run-based model loading is a separate workflow from passing a typed KFP Model between components. section 9.3.4 section 7.2.3

How Machine Learning Platform Engineering covers it

How deep it goes
Shows typed training and validation components and model paths, but does not specify a required model file layout.
Examples
Uses a component that saves a trained model and a YOLO validator that loads best.pt and logs mAP.
What it assumes
Assumes Python component functions and model training; illustrates the relevant KFP input and output annotations.
What you can do after
Apply it via KFP annotations to produce a trained model and pass it into a validation component.
How it connects
Connects Dataset, Model, and Metrics artifacts through training and validation, with MLflow supplying separate experiment tracking.

Also explained in

Compare how 2 books explain model artifact →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.