Skip to main content

A framework for machine learning model serving

Project description

The easiest way to build Machine Learning APIs

Multi-framework / High-performance / Easy to learn / Production ready

pypi status Downloads Actions Status Documentation Status join BentoML Slack

What does BentoML do?

  • Package models trained with any ML framework and reproduce them for model serving in production
  • Package once and deploy anywhere for real-time API serving or offline batch serving
  • High-Performance API model server with adaptive micro-batching support
  • Central storage hub with Web UI and APIs for managing and accessing packaged models
  • Modular and flexible design allowing advanced users to easily customize

BentoML is a framework for serving, managing and deploying machine learning models. It is aiming to bridge the gap between Data Science and DevOps, and enable data science teams to continuesly deliver prediction services to production.

👉 Join the community: BentoML Slack Channel and BentoML Discussions.


How BentoML works

BentoML provides abstractions for creating prediction service that's bundled with one or multiple trained models. User can define inference APIs with serving logic with Python code and specify the expected input/output data format:

import pandas as pd

from bentoml import env, artifacts, api, BentoService
from bentoml.adapters import DataframeInput
from bentoml.frameworks.sklearn import SklearnModelArtifact

from my_library import preprocess

@env(infer_pip_packages=True)
@artifacts([SklearnModelArtifact('my_model')])
class MyPredictionService(BentoService):
    """
    A minimum prediction service exposing a Scikit-learn model
    """

    @api(input=DataframeInput(orient="records"), batch=True)
    def predict(self, df: pd.DataFrame):
        """
        An inference API named `predict` with Dataframe input adapter, which codifies
        how HTTP requests or CSV files are converted to a pandas Dataframe object as the
        inference API function input
        """
        model_input = preprocess(df)
        return self.artifacts.my_model.predict(model_input)

At the end of your model training pipeline, import your BentoML prediction service class, pack it with your trained model, and persist the entire prediction service with save call at the end:

from my_prediction_service import MyPredictionService
svc = MyPredictionService()
svc.pack('my_model', my_sklearn_model)
svc.save()  # default saves to ~/bentoml/repository/MyPredictionService/{version}/

This will save all the code, files, serialized models, and configs required for reproducing this prediction service for inference. BentoML automatically find all the pip package dependencies and local python code dependencies, and make sure all those are packaged and versioned with your code and model in one place.

With the saved prediction service, a user can easily start a local API server hosting it:

bentoml serve MyPredictionService:latest

And create a docker container image for this API model server with just one command:

bentoml containerize my_prediction_service MyPredictionService:latest -t my_prediction_service

docker run -p 5000:5000 my_prediction_service

BentoML will make sure the container has all the required dependencies installed. In addition to the model inference API, this containerized BentoML model server also comes with instrumentations, metrics/healthcheck endpoints, prediction logging, tracing and it is thus ready for your DevOps team to deploy in production.

If you are at a small team without DevOps support, BentoML also provides an one-click deployment option, which deploys the model server API to cloud platforms with minimum setup.

Read the Quickstart Guide to learn more about the basic functionalities of BentoML. You can also try it out here on Google Colab.

Documentation

BentoML documentation: https://docs.bentoml.org/

Kye Features

Online serving with API model server:

  • Containerized model server for production deployment with Docker, Kubernetes, OpenShift, AWS ECS, Azure, GCP GKE, etc
  • Adaptive micro-batching for optimal online serving performance
  • Discover and package all dependencies automatically, including PyPI, conda packages and local python modules
  • Support multiple ML frameworks including PyTorch, TensorFlow, Scikit-Learn, XGBoost, and many more
  • Serve compositions of multiple models
  • Serve multiple endpoints in one model server
  • Serve any Python code along with trained models
  • Automatically generate HTTP API spec in Swagger/OpenAPI format
  • Prediction logging and feedback logging endpoint
  • Health check endpoint and Prometheus /metrics endpoint for monitoring
  • Load and replay historical prediction request logs (roadmap)
  • Model serving via gRPC endpoint (roadmap)

Advanced workflow for model serving and deployment:

  • Central repository for managing all your team's packaged models via Web UI and API
  • Launch inference run from CLI or Python, which enables CI/CD testing, programmatic access and batch offline inference job
  • One-click deployment to cloud platforms including AWS Lambda, AWS SageMaker, and Azure Functions
  • Distributed batch job or streaming job with Apache Spark (improved Spark support is on roadmap)
  • Advanced model deployment workflows for Kubernetes, including auto-scaling, scale-to-zero, A/B testing, canary deployment, and multi-armed-bandit (roadmap)
  • Deep integration with ML experimentation platforms including MLFlow, Kubeflow (roadmap)

ML Frameworks

Deployment Options

Be sure to check out deployment overview doc to understand which deployment option is best suited for your use case.

Why BentoML

Moving trained Machine Learning models to serving applications in production is hard. It is a sequential process across data science, engineering and DevOps teams: after a model is trained by the data science team, they hand it over to the engineering team to refine and optimize code and creates an API, before DevOps can deploy.

And most importantly, Data Science teams want to continously repeat this process, monitor the models deployed in production and ship new models quickly. It often takes months for an engineering team to build a model serving & deployment solution that allow data science teams to ship new models in a repeatable and reliable way.

BentoML is a framework designed to solve this problem. It provides high-level APIs for Data Science team to create prediction services, abstract away DevOps' infrastructure needs and performance optimizations in the process. This allows DevOps team to seamlessly work with data science side-by-side, deploy and operate their models packaged in BentoML format in production.

Check out Frequently Asked Questions page on how does BentoML compares to Tensorflow-serving, Clipper, AWS SageMaker, MLFlow, etc.

Contributing

Have questions or feedback? Post a new github issue or discuss in our Slack channel: join BentoML Slack

Want to help build BentoML? Check out our contributing guide and the development guide.

Releases

BentoML is under active development and is evolving rapidly. Currently it is a Beta release, we may change APIs in future releases.

Read more about the latest features and changes in BentoML from the releases page.

Usage Tracking

BentoML by default collects anonymous usage data using Amplitude. It only collects BentoML library's own actions and parameters, no user or model data will be collected. Here is the code that does it.

This helps BentoML team to understand how the community is using this tool and what to build next. You can easily opt-out of usage tracking by running the following command:

# From terminal:
bentoml config set usage_tracking=false
# From python:
import bentoml
bentoml.config().set('core', 'usage_tracking', 'False')

License

Apache License 2.0

FOSSA Status

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BentoML-0.9.0rc0.tar.gz (2.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

BentoML-0.9.0rc0-py3-none-any.whl (3.0 MB view details)

Uploaded Python 3

File details

Details for the file BentoML-0.9.0rc0.tar.gz.

File metadata

  • Download URL: BentoML-0.9.0rc0.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.3.1.post20200810 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.8

File hashes

Hashes for BentoML-0.9.0rc0.tar.gz
Algorithm Hash digest
SHA256 739237223d5819a5d4b4abd071ae1f974512fe2aeb1a0bcf0d7a08b7c3d1baa9
MD5 6b3cf0d16ab5d13b29087e513bc3517c
BLAKE2b-256 2756fd1afb329513946fdffbaa780269371a2c6e1ec19b573c4d064793121912

See more details on using hashes here.

File details

Details for the file BentoML-0.9.0rc0-py3-none-any.whl.

File metadata

  • Download URL: BentoML-0.9.0rc0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.3.1.post20200810 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.8

File hashes

Hashes for BentoML-0.9.0rc0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2e952f20c3244ed0aabe98ef1f8e34ce0cd64e8319982074bda8db52fc05a84
MD5 e9bd651e08b8c8cb65437119fe13b788
BLAKE2b-256 12b53673fd7988c548513187dbc9dc1003214539a84300c165f22551e37a1f37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page