ppb5 Kickoff Mlops
ppb5 Kickoff Mlops
Implement MLOps
practices on AWS
Amazon SageMaker
MLOps Workshop
tinyurl.com/mb96dhtp
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 2
Agenda
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
What is MLOps
People, Processes, Technology
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 3
ML and Path to Production
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
ML
Code
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 4
ML and Path to Production
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Machine Monitoring
Data Verification Resource
Management
Configuration
Data Collection
Serving
ML Analysis Tool Infrastructure
Code
Feature Process
Extraction Management Tools
Processes
• Culture
• Lack of cross-functional teams
• Priorities & needs (personas)
• Organizational structure
• Skillsets
• Unique aspects of ML lifecycle
What is MLOps: The combination of People, Processes, and Technology to productionize ML solutions efficiently
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 6
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Why MLOps?
Expected Business Value
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 7
MLOps Foundation Expected Outcomes
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 8
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 9
MLOps Maturity Model
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Model
Models in Production
g Scalable
peratin
O
Reliable
Templatize and
Repeatable Productionize
Introduce Testing, Multiple ML
Monitoring, and Multi- Solutions
Standardize Code account Deployment
Initial Repositories & ML
Solution Deployment
Establish the
Experimentation
Environment
MLOps Maturity
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 10
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 11
MLOPs Initial Phase
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 12
Amazon SageMaker Studio
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 13
ML Solution Lifecycle Automation
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Container
Managed Service
Etc.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 14
Amazon SageMaker Processing
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Container
Code
Inputs
Outputs
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 15
Amazon SageMaker Pipelines
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Step Types
• Processing
• Training
• Tuning
• CreateModel
• RegisterModel
• Transform
• Condition
• Callback
• Lambda Function
• ClarifyCheck
• QualityCheck
• Amazon EMR
• Fail
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 16
Amazon SageMaker Model Registry
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Create model groups in Benchmark and observe the model Track the activities, metrics, and
your model registry versions in your model group and settings per model version
promote versions of the model by
changing their status
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 17
Standardize Repository Structure
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
A STANDARDIZE REPO STRUCTURE WILL HELP TO AUTOMATE DEPLOYMENT AND TESTING OF THE ML
WORKFLOWS.
algorithms/
shared_libraries/
<help_functions1>.py
<help_functions2>.py
preprocessing/ # 1 folder per pre-processing job, order is defined in the ml pipeline logic
<preprocessing_job_name> # e.g computer vision: image rotation
test/
input/ # (optional)
output/ # (optional)
test.py
__main__.py
requirements.txt # define library requirements
image_configuration.json # define docker container image configuration in case of custom containers
training/ # (optional) each one is a training job in SageMaker
<training_job_name>/
__main__.py
requirements.txt
postprocessing/ # each one is a processing job in SageMaker
<postprocessing_job_name>/
__main__.py
requirements.txt
inference/ # (optional) for batch inference
<batch_inference_job_name>/ # one job per training job name if we're building multiple models
__main__.py
requirements.txt
mlpipelines/
training/
ml-pipeline-training.py # Define training ML pipelines using SageMaker Pipeline SDK or Step Functions or other orchestrations
input.json # (optional) ML pipeline configuration to enable reusability
inference/
batch/
ml-pipeline-inference.py # Define batch inference ML pipelines using SageMaker Pipeline SDK or Step Functions or other orchestrations
realtime/
endpoint_config.json
ml-pipeline-orcherstrator/ # define which ML pipeline will be deployed in each account
dev.json
preprod.json
prod.json
notebooks/
*.ipynb # the original notebooks as has been created by the data scientists
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. Repository structure example 18
Data Structure and Versioning of ML pipelines
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 19
MLOPs Initial Phase
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 20
MLOPs Repeatable Phase
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 21
MLOPs Reliable Phase 1/2
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 22
MLOPs Automatic Testing
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 23
MLOPs Reliable Phase 2/2
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 24
How SageMaker Model Deployment Works
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
1 2 3
Prepare your ML model Configure endpoint Real-time HTTP requests
Inference Inference
input Compute / GPU
IAM role request result
selection
Bring your own models, containers, and algorithms; or use ones provided by AWS. Example above illustrates “Real-time Inference”.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 25
Amazon SageMaker Model Monitor
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Inference Results
Input data
predictions
input features input
(single row) features
Historical data Inference Results
Bucket
Prediction
ut s
n p
i ure target Probability (0-100%)
t
Historical Data fea Training Job
Model
SageMaker
Bucket
Endpoint
Data Drift
Detection
Training
SageMaker features SageMaker
Monitor Baseline Statistics Monitor
(.json) Model Metadata Scheduled Job
Bucket
Model Drift
Detection
Training
SageMaker features + target SageMaker
Monitor Baseline Monitor
Statistics (.json) Scheduled Job
https://github.com/aws/amazon-sagemaker-examples/tree/main/sagemaker_model_monitor
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 26
MLOPs Reliable Phase 2/2
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 27
MLOPs Scalable Phase
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 28
MLOps Key Personas and Roles
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Platform Team
Secure Cloud/Data/ML Platform
Advance Analytics Team Data Science Team Business
Data Lake Experimentation & MLOps Viz Dashboards, ML Adoption, & ROI
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 34
Example Timeline to deliver MLOPs Foundation
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
TIMELINE MIGHT VARY DEPENDING ON CUSTOMER SECURITY NEED AND MANUAL PROCESSES
MLOp Foundation
Sprint 1 Sprint 2 Sprint 3 Sprint 4 Sprint 5 Sprint 6
Establish Code Repositories Multi-account Parameterization Templatization Testing
Experimentation & Standardization Deployment & Promotion to
Env. Pipelines Prod
Week 1 2 3 4 5 6 7 8 9 10 11 12
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 35
The Partner Delivery Team
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 36
The Customer Delivery Team
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 37
Team sizing example: ML Use Cases
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
1. Exploratory Data
Analysis (EDA) 1. Code for exploratory data
2. Baseline analysis, modeling, and
Modeling 3. Model Iteration metrics
Data Scientist
4. Finalization 2. Business KPIs
Who will assist the Up to 80 Up to 120 Up to160 Up to 220
implementation of 5. Knowledge 3. Solution Documentation
the ML models on Transfer (KT) person-days person-days person-days person-days
the ML platform
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 39
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
MLOps Resources
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 43
Public Resources
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
MLOps
https://aws.amazon.com/sagemaker/mlops/
How NatWest Group built a scalable, secure, and sustainable MLOps platform
https://aws.amazon.com/blogs/machine-learning/part-1-how-natwest-group-built-a-scalable-secure-and-sustainable-mlops-platform/
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 44
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Amazon SageMaker
MLOps Workshop
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 45
Workshop: Use case
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Bank Telemarketing
• Direct marketing campaigns (phone calls) in a Portuguese banking institution
• Predict if a user will subscribe to a product (bank term deposit) before making a call.
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 46
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Amazon SageMaker
MLOps Workshop
tinyurl.com/mb96dhtp
© 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved. 47
UPDATE THIS PRESENTATION HEADER IN SLIDE MASTER
Thank you!
Iván Castro María Cortés
[email protected] [email protected]