When to use it?
You should use the BentoML Model Deployer to:- Standarize the way you deploy your models to production within your organization.
- if you are looking to deploy your models in a simple way, while you are still able to transform your model into a production ready solution when that time comes.
How do you deploy it?
Within ZenML you can quickly get started with BentoML by simply creating Model Deployer Stack Component with the BentoML flavor. To do so you’ll need to install the required python packages on your local machine to be able to deploy your models:How do you use it?
In order to use the BentoML Model Deployer, We need to understand this three main concepts:BentoML Service and Runner
The first step to be able to deploy your models and use BentoML is to create a bento service which is the main logic that defines how your model will be served, and a bento runner which represents a unit of execution for your model on a remote Python worker. The following example shows how to create a basic bento service and runner that will be used to serve a basic scikit-learn model.ZenML Bento Builder step
Once you have your bento service and runner defined, we can use the built-in bento builder step to build the bento bundle that will be used to serve the model. The following example shows how can call the built-in bento builder step within a ZenML pipeline.ZenML BentoML Deployer step
We have now built our bento bundle, and we can use the built-in bento deployer step to deploy the bento bundle to our local http server. The following example shows how to call the built-in bento deployer step within a ZenML pipeline. Note: the bentoml deployer step can only be used in a local environment.ZenML BentoML Pipeline examples
Once all the steps have been defined, we can create a ZenML pipeline and run it. The bento builder step expects to get the trained model as an input, so we need to make sure either we have a previous step that trains the model and outputs it or load the model from a previous run. Then the deployer step expects to get the bento bundle as an input, so we need to make sure either we have a previous step that builds the bento bundle and outputs it or load the bento bundle from a previous run or external source. The following example shows how to create a ZenML pipeline that trains a model, builds a bento bundle and deploys it to a local http server.Predicting with the local deployed model
Once the model has been deployed we can use the BentoML client to send requests to the deployed model. ZenML will automatically create a BentoML client for you and you can use it to send requests to the deployed model by simply calling the service predict method and passing the input data and the api function name. The following example shows how to use the BentoML client to send requests to the deployed model.From Local to Cloud with bentoctl
Bentoctl helps deploy any machine learning models as production-ready API endpoints into the cloud. It is a command line tool that provides a simple interface to manage your BentoML bundles. The bentoctl CLI provides list of operators which are plugins that interact with cloud services, some of these operators are:- AWS Lambda
- AWS SageMaker
- AWS EC2
- Google Cloud Run
- Google Compute Engine
- Azure Container Instances
- Heroku
bentoctl
CLI and the operator plugin for the cloud service you want to deploy to.
bentoctl
CLI and the operator plugin installed, you can use the bentoctl
CLI to deploy your BentoML bundle to the cloud.