liveBook · Manning

Bento

As explained in Machine Learning Platform Engineering

A Bento is a unified package and file format that bundles a machine-learning application, its model, serving logic, dependencies, and configuration.

A Bento is a deployment-ready archive for an ML application. It packages a trained model with its serving code, dependencies, and configuration so the application can be distributed and deployed as one unit. It replaces the ad hoc task of assembling those pieces separately for each deployment; it is not itself a running container or service. section 6.1 section 10.5

To package an income-classifier API:

  • Import the trained model from MLflow into the local BentoML model store. Check its name and tag with `bentoml models list`. section 6.1.1
  • Define the BentoML service and its runner in `service.py`. The `/predict` endpoint retrieves online features from Feast, prepares the model input, runs inference, and returns a prediction. section 6.1.1
  • Define `bentofile.yaml` with the service entry point, files to include, Python requirements, and Docker environment settings. The build configuration determines what accompanies the service. section 6.1.1
  • Run `bentoml build -f bento/bentofile.yaml`. Inspect the resulting Bento with `bentoml list`, then test it locally before pushing it to a remote Bento store. section 6.1.2
Listing 6.4 bentofile.yaml to package our application
service: "service:svc"
labels:
  owner: ml-engineering-team
include:
  - "service.py"
  - "production.env"
  - "src/*.py"
  - "requirements.txt"
  - "*.env"
python:
  requirements_txt: requirements.txt
docker:
  env:
    - ENV_NAME=local
    - AWS_ACCESS_KEY_ID=minio
    - AWS_SECRET_ACCESS_KEY=minio123

The income-classifier `bentofile.yaml` shows the service entry point alongside included source files, a requirements file, and environment settings. Check this manifest when a build lacks code or configuration the service needs. section 6.1.1

A successful build receives a tag such as `income_classifier_service:2umhoidopolz3ktg`, identifying that version of the service. `bentoml list` reports application size separately from model size. Containerization is a subsequent step: `bentoml containerize` can create a Docker image, while Yatai can build an image after a Bento is pushed for deployment. section 6.1.2 section 6.1.3

For a Kubernetes deployment, push the tested Bento to Yatai and verify both the Bento and model in their remote stores. Select the Bento and tag when creating a deployment, then configure replicas and CPU and memory resources. Yatai launches an API Server to receive requests and Runner pods to perform inference; these can be scaled independently. Verify the pods and exercise the deployed `/predict` endpoint. section 6.1.2 section 6.1.3

Another packaging path: object detection

An object-detection service uses a `bentofile.yaml` that includes `service.py` and `yolov8_custom.pt` and specifies an Ultralytics CPU base image. Running `bentoml build` produces a tagged Bento; `bentoml containerize` then turns that package into a container image. The same packaging step can also follow an inference service that imports a registered recommender model from MLflow. section 10.5 section 10.6

How Machine Learning Platform Engineering covers it

How deep it goes
Works through model import, service definition, build configuration, tagging, pushing, and deployment rather than archive-format internals.
Examples
Uses an income-classifier API, a YOLOv8 object-detection service, and an MLflow-backed recommender inference service.
What it assumes
Assumes a trained model and serving logic; introduces the BentoML packaging workflow without requiring readers to assemble Docker and Kubernetes deployment files themselves.
What you can do after
Build it from scratch with BentoML commands, test it locally, and push a tagged package for deployment through Yatai.
How it connects
Connects MLflow model registration, BentoML services and runners, Feast feature retrieval, Docker containerization, and Kubernetes deployment through Yatai.

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.