πŸ€– AI/ML

Seldon

Seldon Core / Seldon Enterprise Platform

A Kubernetes-based platform for ML model deployment and serving. Supports the entire MLOps lifecycle, including model deployment, A/B testing, canary deployment, explainability, and drift monitoring.

πŸ“– Detailed Explanation

Seldon is an open-source platform for deploying and managing machine learning models in production on Kubernetes. It was developed by Seldon Technologies, a UK company founded in 2018, and is widely used in enterprise environments such as finance, automotive, and insurance. Seldon's core philosophy is to provide "a standardized serving layer that supports every ML framework."

Seldon's product lineup consists of three main parts. MLServer is an open-source inference server under the Apache 2.0 license that serves models through REST/gRPC APIs. Seldon Core is a deployment framework based on Kubernetes CRDs (Custom Resource Definitions), and lets you define complex inference graphs through the SeldonDeployment resource. Seldon Enterprise Platform is a commercial version that includes a GUI-based management tool, advanced monitoring, and technical support.

The core feature of Seldon Core is the Inference Graph. Beyond deploying a single model, you can define complex deployment patterns in a single YAML file, such as connecting multiple models as a pipeline (A→B→C), A/B testing, canary deployments, ensembles, and routers. In addition, Alibi Explain and Alibi Detect provide model explainability (SHAP, Anchors, etc.) and data drift/outlier detection out of the box.

Starting in January 2024, the license of the Seldon Core v1, v2, and Alibi projects changed from Apache 2.0 to BSL 1.1 (Business Source License). This means that a license purchase is required to offer them as a commercial SaaS, but use within your own infrastructure remains free. MLServer continues to remain under Apache 2.0. Seldon Core+ is an enterprise version that provides tested binaries, SLA support, and dedicated technical support.

πŸ’» Code Example

This is an example of deploying a scikit-learn model to Kubernetes using Seldon Core.

# 1. λͺ¨λΈ ν•™μŠ΅ 및 μ €μž₯ (model.py)
import joblib
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import load_iris

# λͺ¨λΈ ν•™μŠ΅
iris = load_iris()
model = LogisticRegression(max_iter=200)
model.fit(iris.data, iris.target)

# λͺ¨λΈ μ €μž₯
joblib.dump(model, "model.joblib")


# 2. Seldon 래퍼 클래슀 μž‘μ„± (MyModel.py)
import joblib

class MyModel:
    def __init__(self):
        self.model = joblib.load("model.joblib")

    def predict(self, X, features_names=None):
        """
        X: numpy array ν˜•νƒœμ˜ μž…λ ₯ 데이터
        returns: 예츑 결과
        """
        return self.model.predict(X)

    def predict_proba(self, X, features_names=None):
        """ν™•λ₯  예츑 (선택적)"""
        return self.model.predict_proba(X)


# 3. Dockerfile
"""
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY model.joblib .
COPY MyModel.py .
EXPOSE 9000
CMD ["seldon-core-microservice", "MyModel", "--service-type", "MODEL"]
"""

# 4. requirements.txt
"""
seldon-core
scikit-learn
joblib
"""

SeldonDeployment YAML Definition

# seldon-deployment.yaml
apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
  name: iris-model
  namespace: seldon
spec:
  predictors:
  - name: default
    replicas: 2
    graph:
      name: classifier
      implementation: SKLEARN_SERVER
      modelUri: gs://your-bucket/iris-model
      # λ˜λŠ” μ»€μŠ€ν…€ 이미지 μ‚¬μš©:
      # children: []
      # implementation: null
      # name: classifier
    componentSpecs:
    - spec:
        containers:
        - name: classifier
          image: your-registry/iris-model:v1
          resources:
            requests:
              memory: "256Mi"
              cpu: "100m"
            limits:
              memory: "512Mi"
              cpu: "500m"
    traffic: 100

---
# A/B ν…ŒμŠ€νŠΈ 예제
apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
  name: iris-ab-test
spec:
  predictors:
  - name: model-a
    traffic: 80
    graph:
      name: classifier-a
      implementation: SKLEARN_SERVER
      modelUri: gs://bucket/model-v1
  - name: model-b
    traffic: 20
    graph:
      name: classifier-b
      implementation: SKLEARN_SERVER
      modelUri: gs://bucket/model-v2

Deployment and Testing

# Seldon Core μ„€μΉ˜ (Helm)
helm repo add seldon https://storage.googleapis.com/seldon-charts
helm repo update
helm install seldon-core seldon-core-operator \
  --namespace seldon-system \
  --create-namespace \
  --set usageMetrics.enabled=true

# λͺ¨λΈ 배포
kubectl apply -f seldon-deployment.yaml

# 배포 μƒνƒœ 확인
kubectl get seldondeployments -n seldon
kubectl get pods -n seldon

# μΆ”λ‘  μš”μ²­ (curl)
curl -X POST http://<INGRESS_IP>/seldon/seldon/iris-model/api/v1.0/predictions \
  -H "Content-Type: application/json" \
  -d '{"data": {"ndarray": [[5.1, 3.5, 1.4, 0.2]]}}'

# Python ν΄λΌμ΄μ–ΈνŠΈ
import requests
import json

url = "http://<INGRESS_IP>/seldon/seldon/iris-model/api/v1.0/predictions"
payload = {"data": {"ndarray": [[5.1, 3.5, 1.4, 0.2], [6.2, 3.4, 5.4, 2.3]]}}

response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2))

πŸ“Š Performance & Cost

Seldon is available in open-source and enterprise editions.

Product License Price Key features
MLServer Apache 2.0 Free REST/gRPC inference server, multi-model support
Seldon Core BSL 1.1 Free* K8s deployment, inference graph, A/B testing
Seldon Core+ Commercial Custom Tested binaries, SLA support, technical support
Enterprise Platform Commercial Custom GUI dashboard, advanced monitoring, GenAI support

* Free for use within your own infrastructure; license required to offer as a commercial SaaS

Feature Comparison

Feature Core (Open Source) Core+ Enterprise Platform
Model Deployment O O O
A/B Testing, Canary O O O
Alibi Explain/Detect O (BSL) O O
Multi-Model Serving O O (Optimized) O (Optimized)
GUI Dashboard X X O
GenAI/LLM Support Limited Add-on O
Technical Support Community SLA Included Dedicated Team

πŸ—£οΈ Say It Like This in Practice

Correct Expression

"When deploying a new model, if you do a canary deployment with Seldon, you can test with just 10% of the traffic first. If there are no problems, you can gradually increase it."

Correct Expression

"If you need model explanations, you can attach Alibi Explain to Seldon and provide SHAP values through an API, without building an additional server."

Incorrect Expression

"Just train the model with Seldon." β†’ Seldon is a serving platform, not a training platform. Training is done in a separate environment, and the model is deployed with Seldon.

⚠️ Common Mistakes & Cautions

  • Kubernetes required: Seldon Core requires a Kubernetes environment. It cannot be used with Docker alone; at minimum, you need something like minikube.
  • License change caution: Starting in January 2024, Core and Alibi changed to BSL 1.1. A commercial license is required to offer SaaS services.
  • Istio/Ambassador setup: To receive external traffic, you need to configure an Ingress (Istio, Ambassador, etc.). With the default installation alone, access is only possible from within the cluster.
  • Model formats: Standard servers such as sklearn, xgboost, and tensorflow are provided, but custom models require writing a wrapper class.
  • Resource settings: In production, be sure to set requests/limits. The defaults are too small for anything beyond testing.
  • Monitoring integration: Integrate with Prometheus and Grafana to collect metrics. The built-in metrics alone make production operation difficult.

πŸ”— Related Terms

πŸ“š Learn More