Environment:SeldonIO Seldon core Python ML Dependencies Environment
| Knowledge Sources | |
|---|---|
| Domains | Machine_Learning, Python |
| Last Updated | 2026-02-13 14:00 GMT |
Overview
Python environment with scikit-learn, alibi-detect, alibi-explain, transformers, and MLServer for training model artifacts and custom models used in Seldon Core 2 examples.
Description
This environment provides the Python ML stack required to train and package model artifacts for deployment with Seldon Core 2. It includes scikit-learn for classic ML models, alibi-detect for drift and outlier detection, alibi-explain for model explainability (Anchor Tabular, Anchor Text, Kernel SHAP), HuggingFace transformers for NLP models, and MLServer for custom Python model runtime. Models are serialized using joblib or pickle and served via MLServer (sklearn, alibi-detect, alibi-explain runtimes) or Triton.
Usage
Use this environment for training model artifacts (classifiers, drift detectors, outlier detectors, explainers) and developing custom MLServer models (input/output transforms, pandasquery filters). It is the prerequisite for running any of the training scripts in `samples/scripts/` and `samples/examples/`.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux / macOS / Windows | Python 3.8+ required |
| Python | 3.8+ | 3.10+ recommended for HuggingFace models |
| Memory | 4Gi minimum | 8Gi+ for HuggingFace model training |
| Disk | 5Gi free | HuggingFace models require download cache |
Dependencies
Core ML Packages
- `scikit-learn` (for iris, income, movie sentiment classifiers)
- `joblib` (for model serialization)
- `numpy` (array manipulation)
- `pandas` (data handling, pandasquery models)
Drift and Outlier Detection
- `alibi-detect` == 0.11.1 (for TabularDrift, OutlierVAE)
- `tensorflow` (required by alibi-detect OutlierVAE)
Model Explainability
- `alibi` (for AnchorTabular, AnchorText, KernelShap)
- `spacy` (required by AnchorText explainer)
HuggingFace NLP
- `transformers` (for text-generation, sentiment-analysis, speech-to-text)
- `torch` (PyTorch backend for transformers)
- `torchaudio` (for Whisper speech-to-text)
MLServer Runtime
- `mlserver` >= 1.2.0 (for custom Python models)
Additional Frameworks
- `xgboost` (for income-xgb model)
- `lightgbm` (for income-lgb model)
- `mlflow` (for wine-mlflow model)
Credentials
No credentials required for local model training.
For HuggingFace model downloads (if using gated models):
- `HF_TOKEN`: HuggingFace API token (Read access)
Quick Install
# Core ML packages
pip install scikit-learn joblib numpy pandas
# Drift and outlier detection
pip install alibi-detect==0.11.1
# Model explainability
pip install alibi
python -m spacy download en_core_web_md
# HuggingFace models
pip install transformers torch torchaudio
# MLServer custom models
pip install mlserver>=1.2.0
# Additional frameworks
pip install xgboost lightgbm mlflow
Code Evidence
Income classifier training from `samples/examples/income_classifier/train.py:1-15`:
from sklearn.compose import ColumnTransformer
from sklearn.linear_model import LogisticRegression
from sklearn.pipeline import Pipeline
from alibi.explainers import AnchorTabular
from alibi_detect.cd import TabularDrift
from alibi_detect.od import OutlierVAE
HuggingFace model save from `samples/scripts/models/huggingface-text-gen-gpt2/train.py:1-19`:
from transformers import pipeline
generator = pipeline('text-generation', model='gpt2')
generator.save_pretrained("gpt2")
Image classifier outlier detector training from `samples/examples/image_classifier/requirements.txt`:
alibi-detect==0.11.1
MLServer custom model from `samples/examples/pandasquery/pandasquery/model.py:1-10`:
from mlserver import MLModel
from mlserver.types import InferenceRequest, InferenceResponse
import pandas as pd
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ModuleNotFoundError: No module named 'alibi_detect'` | alibi-detect not installed | `pip install alibi-detect==0.11.1` |
| `OSError: Can't load tokenizer for 'gpt2'` | transformers not installed or cache corrupted | `pip install transformers` and clear cache: `rm -rf ~/.cache/huggingface` |
| `spacy.load('en_core_web_md') failed` | spacy model not downloaded | `python -m spacy download en_core_web_md` |
| `ImportError: MLServer requires Python 3.8+` | Wrong Python version | Use Python 3.8+ (3.10+ recommended) |
Compatibility Notes
- alibi-detect: Version 0.11.1 is pinned in examples; newer versions may have API changes.
- MLServer: Version 1.7.1 is used as the default inference server image; custom models should target this API.
- TensorFlow vs PyTorch: alibi-detect OutlierVAE requires TensorFlow; HuggingFace models use PyTorch. Both can coexist but increase disk/memory usage.
- spacy models: AnchorText explainer requires a spacy language model (e.g., `en_core_web_md`).