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 Infer Explainer

From Leeroopedia
Field Value
Type Wrapper Doc
Overview Concrete CLI tool for generating explanations by sending inference requests to explainer endpoints in Seldon Core 2.
Domains Explainability, Inference
Workflow Model_Explainability
Related Principle SeldonIO_Seldon_core_Explanation_Generation
Source samples/explainer-examples.md:L65-146, docs-gb/cli/seldon_model_infer.md:L1-35
Last Updated 2026-02-13 00:00 GMT

Code Reference

CLI Command Syntax

Source: docs-gb/cli/seldon_model_infer.md:L1-35

seldon model infer <model-name> <json-payload> [flags]

Tabular Explanation Request

Source: samples/explainer-examples.md:L65-100

seldon model infer income-explainer \
  '{"inputs": [{"name": "predict", "shape": [1, 12], "datatype": "FP32", "data": [[39,7,1,1,1,1,4,1,2174,0,40,9]]}]}'

Text Explanation Request

Source: samples/explainer-examples.md:L105-146

seldon model infer sentiment-explainer \
  '{"inputs": [{"name": "predict", "shape": [1], "datatype": "BYTES", "data": ["a]"}]}'

Key Parameters

Parameter Description Example
explainerName Name of the deployed explainer model income-explainer, sentiment-explainer
inputs[].name Input tensor name predict
inputs[].shape Tensor shape [1, 12] for tabular, [1] for text
inputs[].datatype Data type FP32 for numeric features, BYTES for text
inputs[].data Input feature values 39,7,1,1,1,1,4,1,2174,0,40,9 or ["a]"

I/O Contract

Inputs

  • V2 JSON payload: A JSON object conforming to the V2 inference protocol, with input features matching the base model's expected format:
    • Tabular (FP32): Numeric array with shape matching the model's feature count
    • Text (BYTES): String array with the text to explain

Outputs

  • V2 response with explanation metadata:
    • anchor: List of anchor features/conditions that guarantee the prediction (e.g., ["Marital Status = Separated", "Age > 37"])
    • precision: Precision score of the anchor (fraction of perturbations where prediction holds when anchor conditions are met)
    • coverage: Coverage metric (fraction of the dataset where the anchor applies)
    • raw.feature: Arrays with covered_true and covered_false examples showing perturbation results
    • meta.params: Explainer configuration parameters used during explanation generation

External Dependencies

  • seldon CLI
  • curl (alternative to CLI)
  • V2 inference protocol
  • Alibi-Explain runtime on MLServer

Usage Examples

Generating a Tabular Explanation

# Request an explanation for an income prediction
seldon model infer income-explainer \
  '{"inputs": [{"name": "predict", "shape": [1, 12], "datatype": "FP32", "data": [[39,7,1,1,1,1,4,1,2174,0,40,9]]}]}'

# Example response (truncated) includes:
# - anchor: ["Marital Status = Separated", "Capital Gain <= 0"]
# - precision: 0.97
# - coverage: 0.42

Generating a Text Explanation

# Request an explanation for a sentiment prediction
seldon model infer sentiment-explainer \
  '{"inputs": [{"name": "predict", "shape": [1], "datatype": "BYTES", "data": ["a]"}]}'

# Example response includes:
# - anchor: words whose presence anchors the prediction
# - precision: probability the prediction holds with anchor words
# - coverage: fraction of texts where the anchor applies

Using curl as an Alternative

# Direct HTTP request to the explainer endpoint
curl -X POST http://<inference-gateway>/v2/models/income-explainer/infer \
  -H "Content-Type: application/json" \
  -d '{"inputs": [{"name": "predict", "shape": [1, 12], "datatype": "FP32", "data": [[39,7,1,1,1,1,4,1,2174,0,40,9]]}]}'

Knowledge Sources

Related Pages

Page Connections

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