-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from ruivieira/docs-kserve-explainer
docs: Add KServe explainer tutorial
- Loading branch information
Showing
16 changed files
with
546 additions
and
193 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions
20
docs/modules/ROOT/attachments/kserve-explainer-payload.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"instances": [ | ||
[ | ||
404, | ||
1, | ||
1, | ||
20, | ||
1, | ||
144481.56, | ||
1, | ||
56482.48, | ||
1, | ||
372, | ||
0, | ||
0, | ||
1, | ||
2 | ||
] | ||
] | ||
} |
16 changes: 16 additions & 0 deletions
16
docs/modules/ROOT/examples/inference-service-explainer-lime-k8s.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: "serving.kserve.io/v1beta1" | ||
kind: "InferenceService" | ||
metadata: | ||
name: "explainer-test-lime" | ||
spec: | ||
predictor: <1> | ||
model: | ||
modelFormat: | ||
name: sklearn | ||
protocolVersion: v2 | ||
runtime: kserve-sklearnserver | ||
storageUri: https://github.com/trustyai-explainability/model-collection/raw/bank-churn/model.joblib <2> | ||
explainer: <3> | ||
containers: | ||
- name: explainer | ||
image: quay.io/trustyai/trustyai-kserve-explainer:latest <4> |
20 changes: 20 additions & 0 deletions
20
docs/modules/ROOT/examples/inference-service-explainer-lime.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: "serving.kserve.io/v1beta1" | ||
kind: "InferenceService" | ||
metadata: | ||
name: "explainer-test-lime" | ||
annotations: | ||
sidecar.istio.io/inject: "true" | ||
sidecar.istio.io/rewriteAppHTTPProbers: "true" | ||
serving.knative.openshift.io/enablePassthrough: "true" | ||
spec: | ||
predictor: <1> | ||
model: | ||
modelFormat: | ||
name: sklearn | ||
protocolVersion: v2 | ||
runtime: kserve-sklearnserver | ||
storageUri: https://github.com/trustyai-explainability/model-collection/raw/bank-churn/model.joblib <2> | ||
explainer: <3> | ||
containers: | ||
- name: explainer | ||
image: quay.io/trustyai/trustyai-kserve-explainer:latest <4> |
38 changes: 38 additions & 0 deletions
38
docs/modules/ROOT/examples/kserve-explainer-lime-saliencies.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"timestamp": "2024-05-06T21:42:45.307+00:00", | ||
"type": "explanation", | ||
"saliencies": { | ||
"outputs-0": [ | ||
{ | ||
"name": "inputs-12", | ||
"score": 0.8496797810357467, | ||
"confidence": 0 | ||
}, | ||
{ | ||
"name": "inputs-5", | ||
"score": 0.6830766647546147, | ||
"confidence": 0 | ||
}, | ||
{ | ||
"name": "inputs-7", | ||
"score": 0.6768475400887952, | ||
"confidence": 0 | ||
}, | ||
{ | ||
"name": "inputs-9", | ||
"score": 0.018349706373627164, | ||
"confidence": 0 | ||
}, | ||
{ | ||
"name": "inputs-3", | ||
"score": 0.10709513039521452, | ||
"confidence": 0 | ||
}, | ||
{ | ||
"name": "inputs-11", | ||
"score": 0, | ||
"confidence": 0 | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"instances": [ | ||
[ | ||
404, | ||
1, | ||
1, | ||
20, | ||
1, | ||
144481.56, | ||
1, | ||
56482.48, | ||
1, | ||
372, | ||
0, | ||
0, | ||
1, | ||
2 | ||
] | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
= KServe explainer | ||
|
||
image::trustyai-kserve-explainer.svg[TrustyAI KServe architecture diagram] | ||
|
||
The TrustyAI KServe Explainer is a component that provides explanations for predictions made by using the built-in KServe explainer support footnote:fn-kserveexplainer[Documentation available at https://kserve.github.io/website/0.12/modelserving/explainer/explainer/[KServe explainers section].]. It supports xref:local-explainers.adoc#lime[LIME] and xref:local-explainers.adoc#shap[SHAP] explanation methods, configurable directly within KServe `InferenceServices`. | ||
|
||
== Features | ||
|
||
- **Explainability**: Integrated support for xref:local-explainers.adoc#lime[LIME] and xref:local-explainers.adoc#shap[SHAP] explanation methods to interpret model predictions via the `:explain` endpoint. | ||
|
||
== Deployment on KServe | ||
|
||
The TrustyAI explainer can be added to KServe `InferenceServices` and can be configured to use either xref:local-explainers.adoc#lime[LIME] or xref:local-explainers.adoc#shap[SHAP] explanation methods by modifying the YAML configuration. | ||
|
||
When deployed, KServe manages the routing of requests to the appropriate container. Calls to `/v1/models/model:predict` will be sent to the predictor container, while calls to `/v1/models/model:explain` will be sent to the explainer container. The payloads for both endpoints are the same, but the `:predict` endpoint returns the model's prediction, while the `:explain` endpoint returns an explanation of the prediction. | ||
|
||
=== LIME Explainer | ||
|
||
By default, the TrustyAI KServe explainer uses the xref:local-explainers.adoc#lime[LIME] explainer. You can deploy the explainer by specifying the appropriate container image and any necessary configuration in the `InferenceService` YAML. | ||
|
||
=== SHAP Explainer | ||
|
||
To use the xref:local-explainers.adoc#shap[SHAP] explainer, you can deploy the explainer by specifying it as an environment variable in the `InferenceService` YAML configuration. | ||
|
||
== Interacting with the Explainer | ||
|
||
You can interact with the explainer using the `:explain` endpoint. By sending a JSON payload containing the necessary input data, you can retrieve an explanation for the model's prediction. The response structure includes the saliencies of each feature contributing to the prediction. | ||
|
||
A full tutorial on how to deploy the TrustyAI KServe explainer is available at xref:saliency-explanations-with-kserve.adoc[Saliency Explanations with KServe]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.