Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:SeldonIO Seldon core Seldon Pipeline CRD Explainer

From Leeroopedia
Revision as of 13:51, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/SeldonIO_Seldon_core_Seldon_Pipeline_CRD_Explainer.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Field Value
Type Pattern Doc
Overview Concrete pattern for integrating explainers into Seldon Core 2 pipelines with transform steps.
Domains Explainability, Data_Flow
Workflow Model_Explainability
Related Principle SeldonIO_Seldon_core_Explainer_Pipeline_Integration
Source samples/pipelines/sentiment-explain.yaml:L1-16, samples/models/hf-sentiment-explainer.yaml:L1-9
Last Updated 2026-02-13 00:00 GMT

Code Reference

Sentiment Explain Pipeline

Source: samples/pipelines/sentiment-explain.yaml:L1-16

apiVersion: mlops.seldon.io/v1alpha1
kind: Pipeline
metadata:
  name: sentiment-explain
spec:
  steps:
    - name: sentiment
    - name: sentiment-output-transform
      inputs:
      - sentiment
      tensorMap:
        sentiment-explain.inputs.predict: array_inputs
  output:
    steps:
    - sentiment-output-transform

Explainer with pipelineRef

Source: samples/models/hf-sentiment-explainer.yaml:L1-9

apiVersion: mlops.seldon.io/v1alpha1
kind: Model
metadata:
  name: sentiment-explainer
spec:
  storageUri: "gs://seldon-models/scv2/samples/mlserver_1.6.0/huggingface/sentiment-explainer"
  explainer:
    type: anchor_text
    pipelineRef: sentiment-explain

Key Parameters

Parameter Description Example
spec.steps[].name Pipeline step name (references a deployed model) sentiment, sentiment-output-transform
spec.steps[].inputs Input dependencies from other steps - sentiment
spec.steps[].tensorMap Maps input tensor names to the step's expected names sentiment-explain.inputs.predict: array_inputs
spec.output.steps Final output step(s) of the pipeline - sentiment-output-transform
spec.explainer.pipelineRef References the explanation pipeline for black-box inference sentiment-explain
Custom transform model MLServer model extending MLModel to reshape tensors SentimentOutputTransformRuntime

I/O Contract

Inputs

  • Deployed sentiment-explain pipeline: The Pipeline CRD must be loaded with all steps (base model and transform models) available
  • Custom output transform model: A deployed model that reshapes the pipeline's output to match the explainer's expected format
  • Explainer with pipelineRef: The explainer CRD references the pipeline by name

Outputs

  • Pipeline CRD: sentiment-explain: A deployed pipeline that routes inference through the base model and output transform
  • Explainer references pipeline via pipelineRef: The explainer sends its black-box queries through the full pipeline for explanation generation

External Dependencies

  • Kubernetes API
  • Kafka (for pipeline step communication)
  • Custom MLServer transform models (extending MLModel)
  • Seldon scheduler

Usage Examples

Full Pipeline Explainer Deployment

# Step 1: Load the base sentiment model
seldon model load -f samples/models/huggingface-sentiment.yaml
seldon model status sentiment -w ModelAvailable

# Step 2: Load the output transform model
seldon model load -f samples/models/sentiment-output-transform.yaml
seldon model status sentiment-output-transform -w ModelAvailable

# Step 3: Create the explanation pipeline
seldon pipeline load -f samples/pipelines/sentiment-explain.yaml
seldon pipeline status sentiment-explain -w PipelineReady

# Step 4: Load the explainer with pipelineRef
seldon model load -f samples/models/hf-sentiment-explainer.yaml
seldon model status sentiment-explainer -w ModelAvailable

# Step 5: Request an explanation
seldon model infer sentiment-explainer \
  '{"inputs": [{"name": "predict", "shape": [1], "datatype": "BYTES", "data": ["This movie was great"]}]}'

Transform Model Pattern

Custom transform models extend MLServer's MLModel class to reshape tensors between the pipeline's format and the explainer's expected format:

from mlserver import MLModel
from mlserver.types import InferenceRequest, InferenceResponse

class SentimentOutputTransformRuntime(MLModel):
    async def load(self) -> bool:
        # Initialize any required state
        return True

    async def predict(self, payload: InferenceRequest) -> InferenceResponse:
        # Reshape the sentiment model's output tensor
        # to match the explainer's expected input format
        ...

Pipeline tensorMap Explanation

The tensorMap field remaps tensor names between pipeline steps:

tensorMap:
  sentiment-explain.inputs.predict: array_inputs

This maps the pipeline's input tensor sentiment-explain.inputs.predict to the transform model's expected input tensor name array_inputs, enabling seamless data flow without modifying the transform model's code.

Knowledge Sources

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment