Top Related Projects
Standardized Serverless ML Inference Platform on Kubernetes
The easiest way to serve AI apps and models - Build Model Inference APIs, Job queues, LLM apps, Multi-model pipelines, and more!
Open source platform for the machine learning lifecycle
An MLOps framework to package, deploy, monitor and manage thousands of production machine learning models
Production infrastructure for machine learning at scale
A flexible, high-performance serving system for machine learning models
Quick Overview
KServe is an open-source project for serverless inferencing on Kubernetes. It provides a Kubernetes Custom Resource Definition for serving machine learning models on arbitrary frameworks, and aims to solve production model serving use cases by providing performant, high abstraction interfaces for common ML frameworks like TensorFlow, XGBoost, scikit-learn, PyTorch, and ONNX.
Pros
- Supports multiple ML frameworks and custom model servers
- Provides autoscaling, canary rollouts, and other advanced deployment features
- Integrates well with Kubernetes ecosystem and cloud-native technologies
- Offers built-in model explainability and payload logging
Cons
- Steep learning curve for those unfamiliar with Kubernetes
- Requires significant infrastructure setup and maintenance
- May be overkill for simple model serving needs
- Documentation can be complex and sometimes outdated
Code Examples
- Creating a simple InferenceService:
apiVersion: "serving.kserve.io/v1beta1"
kind: "InferenceService"
metadata:
name: "sklearn-iris"
spec:
predictor:
sklearn:
storageUri: "gs://kfserving-examples/models/sklearn/iris"
- Deploying a custom model server:
apiVersion: "serving.kserve.io/v1beta1"
kind: "InferenceService"
metadata:
name: "custom-model"
spec:
predictor:
containers:
- name: custom-model
image: "myrepo/custom-model:v1"
ports:
- containerPort: 8080
- Setting up autoscaling:
apiVersion: "serving.kserve.io/v1beta1"
kind: "InferenceService"
metadata:
name: "autoscale-example"
spec:
predictor:
minReplicas: 1
maxReplicas: 3
tensorflow:
storageUri: "gs://kfserving-examples/models/tensorflow/flowers"
Getting Started
To get started with KServe:
-
Install KServe on your Kubernetes cluster:
kubectl apply -f https://github.com/kserve/kserve/releases/download/v0.8.0/kserve.yaml
-
Create an InferenceService YAML file (e.g.,
inference-service.yaml
) with your model details. -
Apply the InferenceService:
kubectl apply -f inference-service.yaml
-
Check the status of your InferenceService:
kubectl get inferenceservices
For more detailed instructions, refer to the official KServe documentation.
Competitor Comparisons
Standardized Serverless ML Inference Platform on Kubernetes
Pros of KServe
- Comprehensive serverless inference platform for machine learning models
- Supports multiple frameworks and runtimes (TensorFlow, PyTorch, scikit-learn, etc.)
- Provides advanced features like canary rollouts, autoscaling, and model explainability
Cons of KServe
- Steeper learning curve for beginners due to its extensive feature set
- Requires more resources to set up and maintain compared to simpler alternatives
- May be overkill for small-scale or simple inference scenarios
Code Comparison
KServe example:
apiVersion: "serving.kserve.io/v1beta1"
kind: "InferenceService"
metadata:
name: "sklearn-iris"
spec:
predictor:
sklearn:
storageUri: "gs://kfserving-samples/models/sklearn/iris"
As the comparison is between the same repository (kserve/kserve), there isn't a different code example to provide. The code structure and usage would be identical for both cases.
The easiest way to serve AI apps and models - Build Model Inference APIs, Job queues, LLM apps, Multi-model pipelines, and more!
Pros of BentoML
- Simpler setup and deployment process, especially for Python-based models
- Built-in support for various ML frameworks and automatic dependency management
- Flexible serving options, including HTTP, gRPC, and CLI
Cons of BentoML
- Less native integration with Kubernetes compared to KServe
- Fewer advanced features for large-scale production deployments
- Limited support for non-Python models and runtimes
Code Comparison
BentoML:
import bentoml
@bentoml.env(pip_packages=["scikit-learn"])
@bentoml.artifacts([bentoml.SklearnModelArtifact('model')])
class MyService(bentoml.BentoService):
@bentoml.api(input=bentoml.JsonInput())
def predict(self, input_data):
return self.artifacts.model.predict(input_data)
KServe:
from kserve import KFModel
class MyModel(KFModel):
def __init__(self, name):
super().__init__(name)
self.name = name
self.ready = False
def load(self):
self.model = load_model()
self.ready = True
def predict(self, request):
return self.model.predict(request['instances'])
Open source platform for the machine learning lifecycle
Pros of MLflow
- More comprehensive ML lifecycle management, including experiment tracking and model registry
- Language-agnostic with support for Python, R, Java, and more
- Easier to set up and use for local development and small-scale projects
Cons of MLflow
- Less focused on model serving and deployment compared to KServe
- May require additional tools for production-grade serving at scale
- Limited built-in support for advanced serving features like A/B testing and canary deployments
Code Comparison
MLflow example (Python):
import mlflow
mlflow.start_run()
mlflow.log_param("param1", 5)
mlflow.log_metric("accuracy", 0.95)
mlflow.pytorch.log_model(model, "model")
mlflow.end_run()
KServe example (YAML):
apiVersion: "serving.kserve.io/v1beta1"
kind: "InferenceService"
metadata:
name: "pytorch-model"
spec:
predictor:
pytorch:
storageUri: "gs://kserve-models/pytorch/model"
MLflow focuses on tracking experiments and managing the ML lifecycle, while KServe specializes in model serving on Kubernetes. MLflow is more versatile for different ML workflows, but KServe offers more advanced serving capabilities for production environments.
An MLOps framework to package, deploy, monitor and manage thousands of production machine learning models
Pros of Seldon Core
- More flexible and customizable, allowing for complex ML pipelines and custom inference servers
- Supports a wider range of deployment options, including multi-model serving and canary deployments
- Provides advanced features like A/B testing, shadow deployments, and explainers
Cons of Seldon Core
- Steeper learning curve due to its flexibility and complexity
- Requires more configuration and setup compared to KServe's simpler approach
- Less standardized approach to model serving, which may lead to inconsistencies across deployments
Code Comparison
Seldon Core deployment example:
apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
name: iris-model
spec:
predictors:
- graph:
implementation: SKLEARN_SERVER
modelUri: gs://seldon-models/sklearn/iris
name: default
KServe deployment example:
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: sklearn-iris
spec:
predictor:
sklearn:
storageUri: gs://kfserving-examples/models/sklearn/iris
Production infrastructure for machine learning at scale
Pros of Cortex
- Simpler setup and deployment process, especially for beginners
- Built-in support for popular ML frameworks like TensorFlow and PyTorch
- Automatic scaling and load balancing out of the box
Cons of Cortex
- Less flexibility in customization compared to KServe
- Smaller community and ecosystem
- Limited support for advanced features like model explainability
Code Comparison
KServe example:
from kubernetes import client, config
from kserve import KServeClient
config.load_kube_config()
kserve_client = KServeClient()
isvc = {
"apiVersion": "serving.kserve.io/v1beta1",
"kind": "InferenceService",
"metadata": {"name": "sklearn-iris"},
"spec": {
"predictor": {
"sklearn": {
"storageUri": "gs://kfserving-samples/models/sklearn/iris"
}
}
}
}
kserve_client.create(isvc)
Cortex example:
import cortex
cx = cortex.client("aws")
cx.deploy("sklearn-iris.yaml")
# sklearn-iris.yaml
# apiVersion: kind: name: predictor:
# type: python
# path: predictor.py
# model:
# type: sklearn
# path: s3://cortex-examples/sklearn/iris-classifier
Both frameworks offer streamlined deployment of machine learning models, but Cortex provides a more straightforward approach with less configuration required. KServe offers more advanced features and greater customization options, making it suitable for more complex deployment scenarios.
A flexible, high-performance serving system for machine learning models
Pros of TensorFlow Serving
- Highly optimized for TensorFlow models, offering excellent performance
- Supports model versioning and concurrent model serving
- Integrates seamlessly with TensorFlow ecosystem
Cons of TensorFlow Serving
- Limited to TensorFlow models, lacking support for other frameworks
- Steeper learning curve and more complex setup compared to KServe
- Less flexibility in customization and extensibility
Code Comparison
KServe example:
apiVersion: "serving.kserve.io/v1beta1"
kind: "InferenceService"
metadata:
name: "mnist"
spec:
predictor:
tensorflow:
storageUri: "gs://kserve-samples/models/tensorflow/mnist"
TensorFlow Serving example:
import tensorflow as tf
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_service_pb2_grpc
channel = grpc.insecure_channel('localhost:8500')
stub = prediction_service_pb2_grpc.PredictionServiceStub(channel)
KServe offers a more declarative approach with Kubernetes-native resources, while TensorFlow Serving requires more code for setup and interaction. KServe provides a higher level of abstraction and easier deployment, especially in Kubernetes environments.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
KServe
KServe provides a Kubernetes Custom Resource Definition for serving predictive and generative machine learning (ML) models. It aims to solve production model serving use cases by providing high abstraction interfaces for Tensorflow, XGBoost, ScikitLearn, PyTorch, Huggingface Transformer/LLM models using standardized data plane protocols.
It encapsulates the complexity of autoscaling, networking, health checking, and server configuration to bring cutting edge serving features like GPU Autoscaling, Scale to Zero, and Canary Rollouts to your ML deployments. It enables a simple, pluggable, and complete story for Production ML Serving including prediction, pre-processing, post-processing and explainability. KServe is being used across various organizations.
For more details, visit the KServe website.
KFServing has been rebranded to KServe since v0.7.
Why KServe?
- KServe is a standard, cloud agnostic Model Inference Platform for serving predictive and generative AI models on Kubernetes, built for highly scalable use cases.
- Provides performant, standardized inference protocol across ML frameworks including OpenAI specification for generative models.
- Support modern serverless inference workload with request based autoscaling including scale-to-zero on CPU and GPU.
- Provides high scalability, density packing and intelligent routing using ModelMesh.
- Simple and pluggable production serving for inference, pre/post processing, monitoring and explainability.
- Advanced deployments for canary rollout, pipeline, ensembles with InferenceGraph.
Learn More
To learn more about KServe, how to use various supported features, and how to participate in the KServe community, please follow the KServe website documentation. Additionally, we have compiled a list of presentations and demos to dive through various details.
:hammer_and_wrench: Installation
Standalone Installation
- Serverless Installation: KServe by default installs Knative for serverless deployment for InferenceService.
- Raw Deployment Installation: Compared to Serverless Installation, this is a more lightweight installation. However, this option does not support canary deployment and request based autoscaling with scale-to-zero.
- ModelMesh Installation: You can optionally install ModelMesh to enable high-scale, high-density and frequently-changing model serving use cases.
- Quick Installation: Install KServe on your local machine.
Kubeflow Installation
KServe is an important addon component of Kubeflow, please learn more from the Kubeflow KServe documentation. Check out the following guides for running on AWS or on OpenShift Container Platform.
:flight_departure: Create your first InferenceService
:bulb: Roadmap
:blue_book: InferenceService API Reference
:toolbox: Developer Guide
:writing_hand: Contributor Guide
:handshake: Adopters
Top Related Projects
Standardized Serverless ML Inference Platform on Kubernetes
The easiest way to serve AI apps and models - Build Model Inference APIs, Job queues, LLM apps, Multi-model pipelines, and more!
Open source platform for the machine learning lifecycle
An MLOps framework to package, deploy, monitor and manage thousands of production machine learning models
Production infrastructure for machine learning at scale
A flexible, high-performance serving system for machine learning models
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot