Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
avishniakov committed Nov 6, 2023
1 parent 04c3701 commit 1bf0024
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 10 deletions.
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@ to top it all off, a simple but useful CLI. This is exactly
what the ZenML templates are all about.

This project template is a great starting point for anyone looking to deepen their knowledge of ZenML.
It consists of two pipelines with the following high-level setup:
It consists of three pipelines with the following high-level setup:
<p align="center">
<img height=300 src="template/.assets/00_pipelines_composition.png">
<img height=500 src="template/.assets/00_pipelines_composition.png">
</p>

Both pipelines are inside a shared Model Control Plane model context - training pipeline creates and promotes new Model Control Plane version and inference pipeline is reading from inference Model Control Plane version. This makes those pipelines closely connected, while ensuring that only quality assured Model Control Plane versions are used to produce predictions delivered to stakeholders.
All pipelines are leveraging the Model Control Plane to bring all parts together - the training pipeline creates and promotes a new Model Control Plane version with a trained model object in it, deployment pipeline uses the inference Model Control Plane version (the one promoted during training) to create a deployment service and inference pipeline using deployment service from the inference Model Control Plane version and store back new set of predictions as a versioned data artifact for future use. This makes those pipelines closely connected while ensuring that only quality-assured Model Control Plane versions are used to produce predictions delivered to stakeholders.
* [CT] Training
* Load, split, and preprocess the training dataset
* Search for an optimal model object architecture and tune its hyperparameters
* Train the model object and evaluate its performance on the holdout set
* Compare a recently trained model object with one promoted earlier
* If a recently trained model object performs better, then stage it as a new inference model in the Model Control Plane
* If a recently trained model object performs better - stage it as a new inference model object in model registry
* On success of the current model object - stage newly created Model Control Plane version as the one used for inference
* [CD] Deployment
* Deploy a new prediction service based on the model object connected to the inference Model Control Plane version.
* [CD] Batch Inference
* Load the inference dataset and preprocess it reusing object fitted during training
* Perform data drift analysis reusing training dataset of the inference Model Control Plane version as a reference
* Run predictions using a model object from the inference Model Control Plane version
* Store predictions as a versioned artifact and link it to the inference Model Control Plane version
* Store predictions as an versioned artifact and link it to the inference Model Control Plane version

It showcases the core ZenML concepts for supervised ML with batch predictions:

Expand Down Expand Up @@ -231,6 +234,27 @@ To achieve this we would retrieve the model version from the Model Control Plane

By doing so we ensure that the best-performing version will be used for inference later on and ensure seamless integration of relevant artifacts from the training pipeline in the batch inference pipeline.

### [Continuous Deployment] Deployment

The Deployment pipeline is designed to run with inference Model Control Plane version context. This ensures that we always infer only on quality-assured Model Control Plane version and provide seamless integration of required artifacts created during training of this Model Control Plane version.
This is achieved by providing this configuration in `deployer_config.yaml` used to configure our pipeline:
```yaml
model_config:
name: your_product_name
version: production
```

<p align="center">
<img height=500 src="assets/05_deployment.png">
</p>

The deployment pipeline takes the model object trained earlier from the inference Model Control Plane version and produces a prediction service, which can be used by external tools or by another pipeline. In this case it will be used by a batch prediction pipeline later on. Prepared prediction service is linked to the same inference Model Control Plane version.

```
NOTE: In this template a prediction service is only created for local orchestrators, but you can redefine step definition to fit the needs of your infrastructure.
```
### [Continuous Deployment] Batch Inference
The Batch Inference pipeline is designed to run with inference Model Control Plane version context. This ensures that we always infer only on quality-assured Model Control Plane version and provide seamless integration of required artifacts created during training of this Model Control Plane version.
This is achieved by providing this configuration in `inference_config.yaml` used to configure our pipeline:
Expand All @@ -241,7 +265,7 @@ model_config:
```

<p align="center">
<img height=500 src="assets/05_batch_inference.png">
<img height=500 src="assets/06_batch_inference.png">
</p>

### [Continuous Deployment] Batch Inference: ETL Steps
Expand Down Expand Up @@ -286,7 +310,12 @@ You can follow [Data Validators docs](https://docs.zenml.io/stacks-and-component

As a last step concluding all work done so far, we will calculate predictions on the inference dataset and persist them in [Artifact Store](https://docs.zenml.io/stacks-and-components/component-guide/artifact-stores) attached to the current inference model version of the Model Control Plane for reuse and observability.

We will leverage metadata of `model` artifact linked to the inference model version of the Model Control Plane to create a deployment service and run `.predict()` to put those predictions as an output of the predictions step, so it is automatically stored in the [Artifact Store](https://docs.zenml.io/stacks-and-components/component-guide/artifact-stores) and linked to the Model Control Plane model version as a versioned artifact link with zero effort. This is achieved because we additionally annotated the `predictions` output with `ArtifactConfig(overwrite=False)`. This is required to deliver a comprehensive history to stakeholders since Batch Inference can be executed using the same Model Control Plane version multiple times.
We will leverage a prepared predictions service called `mlflow_deployment` linked to the inference model version of the Model Control Plane to run `.predict()` and to put predictions as an output of the predictions step, so it is automatically stored in the [Artifact Store](https://docs.zenml.io/stacks-and-components/component-guide/artifact-stores) and linked to the Model Control Plane model version as a versioned artifact link with zero effort. This is achieved because we additionally annotated the `predictions` output with `ArtifactConfig(overwrite=False)`. This is required to deliver a comprehensive history to stakeholders since Batch Inference can be executed using the same Model Control Plane version multiple times.

```
NOTE: On non-local orchestrators a `model` artifact will be loaded into memory to run predictions directly. You can adapt this part to your needs.
```

<details>
<summary>Code snippet 💻</summary>

Expand Down
Binary file added assets/05_deployment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified template/.assets/00_pipelines_composition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 8 additions & 3 deletions template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,21 @@ This template uses
to demonstrate how to perform major critical steps for Continuous Training (CT)
and Continuous Delivery (CD).

It consists of two pipelines with the following high-level setup:
It consists of three pipelines with the following high-level setup:
<p align="center">
<img height=300 src=".assets/00_pipelines_composition.png">
<img height=500 src=".assets/00_pipelines_composition.png">
</p>

Both pipelines are inside a shared Model Control Plane model context - training pipeline creates and promotes new Model Control Plane version and inference pipeline is reading from inference Model Control Plane version. This makes those pipelines closely connected, while ensuring that only quality-assured Model Control Plane versions are used to produce predictions delivered to stakeholders.
All pipelines are leveraging the Model Control Plane to bring all parts together - the training pipeline creates and promotes a new Model Control Plane version with a trained model object in it, deployment pipeline uses the inference Model Control Plane version (the one promoted during training) to create a deployment service and inference pipeline using deployment service from the inference Model Control Plane version and store back new set of predictions as a versioned data artifact for future use. This makes those pipelines closely connected while ensuring that only quality-assured Model Control Plane versions are used to produce predictions delivered to stakeholders.
* [CT] Training
* Load, split, and preprocess the training dataset
* Search for an optimal model object architecture and tune its hyperparameters
* Train the model object and evaluate its performance on the holdout set
* Compare a recently trained model object with one promoted earlier
* If a recently trained model object performs better - stage it as a new inference model object in model registry
* On success of the current model object - stage newly created Model Control Plane version as the one used for inference
* [CD] Deployment
* Deploy a new prediction service based on the model object connected to the inference Model Control Plane version.
* [CD] Batch Inference
* Load the inference dataset and preprocess it reusing object fitted during training
* Perform data drift analysis reusing training dataset of the inference Model Control Plane version as a reference
Expand All @@ -143,13 +145,16 @@ The project loosely follows [the recommended ZenML project structure](https://do
```
.
├── configs # pipelines configuration files
│ ├── deployer_config.yaml # the configuration of the deployment pipeline
│ ├── inference_config.yaml # the configuration of the batch inference pipeline
│ └── train_config.yaml # the configuration of the training pipeline
├── pipelines # `zenml.pipeline` implementations
│ ├── batch_inference.py # [CD] Batch Inference pipeline
│ ├── deployment.py # [CD] Deployment pipeline
│ └── training.py # [CT] Training Pipeline
├── steps # logically grouped `zenml.steps` implementations
│ ├── alerts # alert developer on pipeline status
│ ├── deployment # deploy trained model objects
│ ├── data_quality # quality gates built on top of drift report
│ ├── etl # ETL logic for dataset
│ ├── hp_tuning # tune hyperparameters and model architectures
Expand Down

0 comments on commit 1bf0024

Please sign in to comment.