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 Model CRD Explainer

From Leeroopedia
Field Value
Type Pattern Doc
Overview Concrete pattern for declaring model explainability configurations in Seldon Core 2 Model CRDs.
Source samples/models/hf-sentiment-explainer.yaml:L1-9
Domains MLOps, Explainability
Implements Principle SeldonIO_Seldon_core_Model_Explainability_Integration
External Dependencies Kubernetes API, MLServer Alibi-Explain runtime, alibi
Knowledge Sources Repo (https://github.com/SeldonIO/seldon-core), Doc (https://docs.seldon.io/projects/alibi), Paper (https://arxiv.org/abs/1804.06506)
Last Updated 2026-02-13 00:00 GMT

Code Reference

Sentiment Explainer Model

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 Example Description
metadata.name sentiment-explainer Name of the explainer model resource
spec.storageUri gs://seldon-models/scv2/samples/mlserver_1.6.0/huggingface/sentiment-explainer Remote URI pointing to the serialized Alibi Explain artifact
spec.explainer.type anchor_text Explanation algorithm; anchor_text for NLP models, anchor_tabular for tabular models
spec.explainer.modelRef (model name, optional) Name of the base model to explain; used when explaining a single model directly
spec.explainer.pipelineRef sentiment-explain Name of the pipeline to use as the black box for generating explanations; used when the base model is accessed through a pipeline

Explainer Types

Type Use Case Description
anchor_text NLP models (sentiment, classification) Identifies minimal sets of words that guarantee the prediction; uses word replacement perturbations
anchor_tabular Tabular data models Identifies feature value ranges that are sufficient for the prediction; uses feature value perturbations

I/O Contract

Inputs

Input Format Description
Explainer model artifact Remote URI Serialized Alibi Explain instance with pre-configured explanation algorithm parameters
Deployed base model or pipeline Kubernetes resource The model or pipeline referenced by modelRef or pipelineRef must be deployed and available

Outputs

Output Format Description
Explainer Model resource Kubernetes Model CRD Explainer model linked to a base model or pipeline; inference returns anchor explanations
Explanation response V2 JSON Anchor text explanation identifying which input features (words) drive the prediction

An example explanation response for a sentiment model:

{
  "outputs": [
    {
      "name": "explanation",
      "datatype": "BYTES",
      "data": ["{\"anchor\": [\"love\"], \"precision\": 0.97, \"coverage\": 0.52}"]
    }
  ]
}

This indicates that the word "love" alone is sufficient (with 97% precision) to produce the POSITIVE classification, and this anchor applies to 52% of similar inputs.

Usage Examples

Deploying the explainer model

seldon model load -f samples/models/hf-sentiment-explainer.yaml
seldon model status sentiment-explainer -w ModelAvailable

Requesting an explanation

seldon model infer sentiment-explainer \
  '{"inputs": [{"name": "args", "shape": [1], "datatype": "BYTES", "data": ["I love this product"]}]}'

Using with a pipeline (speech-to-sentiment)

The explainer is included as a step in the speech-to-sentiment pipeline:

spec:
  steps:
    - name: whisper
    - name: sentiment
      inputs:
      - whisper
      tensorMap:
        whisper.outputs.output: args
    - name: sentiment-input-transform
      inputs:
      - whisper
    - name: sentiment-explainer
      inputs:
      - sentiment-input-transform

In this pipeline, sentiment-explainer receives preprocessed input from sentiment-input-transform and uses the sentiment-explain pipeline (referenced via pipelineRef) as its black box for generating anchor text explanations.

Defining an explainer with modelRef

For simpler cases where the explainer directly references a model (without a pipeline intermediary):

apiVersion: mlops.seldon.io/v1alpha1
kind: Model
metadata:
  name: iris-explainer
spec:
  storageUri: "gs://seldon-models/scv2/samples/mlserver_1.6.0/iris-explainer"
  explainer:
    type: anchor_tabular
    modelRef: iris

Related Pages

Page Connections

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